package com.smart.parking.service.impl;


import com.smart.parking.service.NoticeService;
import com.smart.parking.utils.PageUtils;
import com.smart.parking.utils.Query;
import com.smart.parking.vo.NoticeVO;
import org.springframework.stereotype.Service;

import java.util.Map;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;


import com.smart.parking.mapper.NoticeMapper;
import com.smart.parking.entity.NoticeEntity;


@Service("noticeService")
public class NoticeServiceImpl extends ServiceImpl<NoticeMapper, NoticeEntity> implements NoticeService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<NoticeEntity> page = this.page(
                new Query<NoticeEntity>().getPage(params),
                new QueryWrapper<NoticeEntity>()
        );

        return new PageUtils(page);
    }

    /**
     * 添加公告
     *
     * @param noticeVO 请注意签证官
     */
    @Override
    public void addNotice(NoticeVO noticeVO) {
        NoticeEntity noticeEntity=new NoticeEntity();
        noticeEntity.setValidityTime(noticeVO.getValidityTime());
        noticeEntity.setUserId(noticeVO.getUserId());
        noticeEntity.setViolationId(noticeVO.getViolationEntity().getViolationId());
        baseMapper.insert(noticeEntity);
    }

    /**
     * 删除公告
     *
     * @param noticeId 注意id
     */
    @Override
    public void deleteNotice(Long noticeId) {
        baseMapper.deleteById(noticeId);
    }

}
